package com.spring.springboot.configure;

import java.util.Map;

import javax.persistence.EntityManager;
import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;

/**
*@author LSY
*Time: 2018年12月18日上午11:32:23
*
*
*/
@Configuration
public class DataSourceConfigurer {

	@Bean(name = "user1DataSource")
	@ConfigurationProperties(prefix = "spring.datasource.user1")
	@Primary
	@Qualifier("user1DataSource")
	public DataSource user1DataSource() {
		return DataSourceBuilder.create().build();
	}
	
	@Bean(name = "user2DataSource")
	@ConfigurationProperties(prefix = "spring.datasource.user2")
	@Qualifier("user2DataSource")
	public DataSource user2DataSource() {
		return DataSourceBuilder.create().build();
	}
}
